﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace KML
{
    [Serializable]
    public struct KMLPlacemark
    {
        string name;
        string fullName;
        string descr;
        string styleUrl;
        KMLPoint point;
        KMLIcon? icon;

        internal KMLPlacemark(string name, string descr, string styleUrl, KMLPoint point, KMLIcon? icon, string rootName)
        {
            this.name = name;
            this.descr = descr;
            this.styleUrl = styleUrl;
            this.point = point;
            this.fullName = rootName + "/" + name;
            this.icon = icon;
        }

        public string Name { get { return name; } }
        public string FullName { get { return fullName; } }
        public string Description { get { return descr; } }
        public string StyleUrl { get { return styleUrl; } }
        public KMLPoint Point { get { return point; } }
        public KMLIcon? Icon { get { return icon; } }

        public override string ToString()
        {
            return string.Format("{0} @ {1}", name, point);
        }

        public override int GetHashCode()
        {
            return fullName.GetHashCode();
        }

        public override bool Equals(object obj)
        {
            if (!(obj is KMLPlacemark)) return false;

            return ((KMLPlacemark)obj).fullName == fullName;
        }
    }

    [Serializable]
    public struct KMLIcon
    {
        string href;

        internal KMLIcon(string href)
        {
            this.href = href;
        }

        public string Href { get { return href; } }
    }
}
